package com.e_library.jpa.entities;
import java.sql.DriverManager;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;

import com.e_library.dao.classes.CollectionDaoImpl;
import com.e_library.dao.classes.CollectionIDao;
public class Main {

		/**
		 * @param args
		 */
		
		   
	    @PersistenceContext
	    public  static EntityManager em;
	    static String username="postgres";
	    static String password="sahar" ;
	    static String database="e-library-database";

	 public Main(){

	      System.out.println("--- Initializing context ---");
	    try {
	        Class.forName("org.postgresql.Driver");
	        DriverManager.getConnection("jdbc:postgresql:"+database, username, password).close();
	        } 
	    catch (Exception ex) {
	        ex.printStackTrace();
	                          }
	    try {
	        EntityManagerFactory emFactory = Persistence.createEntityManagerFactory("testjpaproject");
	        em = emFactory.createEntityManager();
	        } 
	    catch (Exception ex) {
	        ex.printStackTrace();
	                         }
		
	        
	              } 
		public static void main(String[] args) {
			//Main n= new Main();
			// TODO Auto-generated method stub
			CollectionIDao collectionIDao=new CollectionDaoImpl();
			 //LivreIDao livreIDao =new LivreDaoImpl();
			// System.out.println( livreIDao.getAllLike("web").size());
			 
		//collectionIDao.deleteOne("coll3");
	System.out.println( collectionIDao.getAll().size());

		}

}
